<template > 
    <div class="leftBox"> 
        <div v-for="(it,idx) in leftMenu" :key = "idx">
            <h2 @click="it.isShow = !Boolean(it.isShow )" style="display: flex;justify-content: space-between;">
                <div>
                <img :src="it.icon" alt="" />
                <span>{{ it.title }}</span>
                </div>
                <span
                ><img
                    :class="{ zhuan1: it.isShow }"
                    src="../../../assets/ic_xuexi_shouq.png"
                    alt=""
                /></span>
            </h2>
            <ul class="cury" v-if="it.isShow&&it.children&&it.children.length>0">
                <li @click = "menuClick(t)" v-for="(t,i) in it.children" :key="i" :class="activeMenu == t.id ? 'active' : ''" >
                    <span :class="activeMenu == t.id ? 'active' : '' " >
                        {{ t.title }}
                    </span>
                </li>
            </ul>
        </div>
            
    </div>
</template>
<script>
import { bus }  from '../../../main.js';
import pagePublic from "@/mixins/pagePublic.js";
import { mapMutations, mapState } from "vuex";

const myCourseIcon = require('../../../assets/ic_xuexi_kec.png')
    export default {
        name: "tem",
        mixins: [pagePublic],
        data(){
            return{
                activeMenu:'startStudy',
                leftMenu: [
                    {
                        id: "myCourse",
                        title: "我的课程",
                        icon: "ic_xuexi_kec",
                        path: "/xxcenter/startLecture",
                        icon:myCourseIcon,
                        isShow:true,
                        children: [
                            {
                                id:"startStudy",
                                title: "开始学习",
                                path: "",
                                isHead:true,

                            },
                            {
                                id:"studyList",
                                title: "学习记录",
                                path: "",
                                isHead:true,

                            }
                        ],
                    },
                    {
                        id: "subjectBank",
                        title: "我的题库",
                        icon: "ic_xuexi_kec",
                        path: "/xxcenter/startLecture",
                        icon:myCourseIcon,
                        isShow:true,
                        children: [
                            {
                                id:"startAnswer",
                                title: "开始答题",
                                path: "",
                                isHead:true,

                            },
                            {
                                id:"answerList",
                                title: "答题记录",
                                path: "",
                                isHead:true,

                            },
                            {
                                id:"collectAnswer",
                                title: "我的收藏",
                                path: "",
                                // isHead:true,

                            },
                            {
                                id:"errAnswer",
                                title: "错题本",
                                path: "",
                                // isHead:true,

                            }
                        ],
                    },
                    {
                        id: "onLine",
                        title: "在线互动",
                        icon: "ic_xuexi_kec",
                        path: "/xxcenter/startLecture",
                        icon:myCourseIcon,
                        isShow:true,
                        children: [
                            {
                                id:"onLineAnswer",
                                title: "在线答疑",
                                path: "",
                                isHead:false,

                            },
                            {
                                id:"onLineComplaint",
                                title: "在线投诉",
                                path: "",
                                isHead:false,

                            },
                            {
                                id:"onLineTeacher",
                                title: "在线班主任",
                                path: "",
                                isHead:false,

                            }
                        ],
                    },
                    {
                        id: "studyTool",
                        title: "学习工具",
                        icon: "ic_xuexi_kec",
                        path: "/xxcenter/startLecture",
                        icon:myCourseIcon,
                        isShow:true,
                        children: [
                            {
                                id:"studyPlan",
                                title: "学习计划",
                                path: "",
                                isHead:false,

                            },
                            {
                                id:"score",
                                title: "考试成绩",
                                path: "",
                                isHead:false,

                            },
                            {
                                id:"msgProd",
                                title: "消息提醒",
                                path: "",
                                isHead:false,

                            },
                        ],
                    },
                    {
                        id: "personalSys",
                        title: "个人管理",
                        icon: "ic_xuexi_kec",
                        path: "/xxcenter/startLecture",
                        icon:myCourseIcon,
                        isShow:true,
                        children: [
                            {
                                id:"information",
                                title: "基本资料",
                                path: "",
                                isHead:false,

                            },
                            {
                                id:"address",
                                title: "收货地址",
                                path: "",
                                isHead:false,

                            },
                            {
                                id:"editPwd",
                                title: "修改密码",
                                path: "",
                                isHead:false,

                            },
                            {
                                id:"editDel",
                                title: "修改手机号",
                                path: "",
                                isHead:false,

                            },
                            {
                                id:"myContract",
                                title: "我的合同",
                                path: "",
                                isHead:false,
                            },
                        ],
                    },
                ],
                // urls:{
                //     list: {
                //         url:this.$api.tem.list,
                //         method:"get",
                //         sync:false,
                //     },
                //     add:this.$api.tem.add,
                //     edit:this.$api.tem.edit,
                //     del:this.$api.tem.del
                // },

                
            }
        },
        computed: {
            ...mapState(['configInfo']),

        },
        created() {
            bus.$emit('leftMenuClick',this.leftMenu[0].children[0])
            localStorage.setItem('defaultMenu',JSON.stringify(this.leftMenu[0].children[0]));
        },
        methods:{
            ...mapMutations(['set_configInfo']),
            menuClick(t){
                this.activeMenu = t.id;
                console.log(this.activeMenu,t.id,222)
                bus.$emit('leftMenuClick',t)
            }
        }
    }
</script>
<!-- <style lang="scss" src="../this.scss"></style> -->
<style lang="scss" scoped>

</style>